﻿using System;
using System.Collections.Generic;
using ProjScan.Config;
using ProjScan.Config.GUIConfig;
using ProjScan.Modules;
using ProjScan.Tools;
using UnityEngine;

namespace ProjScan.ScanGUI.Page
{
	// Token: 0x02000266 RID: 614
	internal class ArtAssetsCheckPage : BasePage<ArtAssetsCheckConfig>
	{
		// Token: 0x06001093 RID: 4243 RVA: 0x00007F20 File Offset: 0x00006120
		public ArtAssetsCheckPage()
		{
			this.pageName = "美术资源检测";
			this.pageId = "Art_Assets_Check";
			this.fixModule = Module.Art_Assets_Fix;
		}

		// Token: 0x06001094 RID: 4244 RVA: 0x0004C044 File Offset: 0x0004A244
		public override void Init()
		{
			this.dicRuleInfo = Singleton<RuleInfoManager>.Instance.dicRuleInfoByPage["9"];
			this.guiActions.Add("Mesh.ImproperPivotPos", new Action(this.CreatePivotPosGUI));
			this.guiActions.Add("Prefab.FaceTexDensityAvgTooSmall", new Action(this.CreateFaceTexDensityAvgGUI));
			this.guiActions.Add("Prefab.FaceTexDensityVrcTooLarge", new Action(this.CreateFaceTexDensityVrcGUI));
			this.guiActions.Add("Mesh.UVRangeTooLarge", new Action(this.CreateUVRangeGUI));
			this.guiActions.Add("Mesh.VertexDensityTooLarge", new Action(this.CreateVertexDensityGUI));
			this.guiActions.Add("Mesh.HasInvisibleFaces", new Action(this.CreateInvisibleFacesGUI));
			this.guiActions.Add("Mesh.HardedgeUVSeamConsistency", new Action(this.CreateUVSeamConsistencyGUI));
			this.guiActions.Add("Mesh.UVPaddingTooSmall", new Action(this.CreateUVPaddingGUI));
			this.CreateRuleGUI();
		}

		// Token: 0x06001095 RID: 4245 RVA: 0x00007F53 File Offset: 0x00006153
		public void CreatePivotPosGUI()
		{
			this.data.improperPivotPosTolerance = GUITools.FloatField("【误差容忍值】: ", 180, this.data.improperPivotPosTolerance, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.ShowAttention("Mesh.ImproperPivotPos");
		}

		// Token: 0x06001096 RID: 4246 RVA: 0x00007F92 File Offset: 0x00006192
		public void CreateFaceTexDensityAvgGUI()
		{
			this.data.faceTexDensityMinSqrtDensity = GUITools.FloatField("【允许最小平均UV密度（像素/米）】: ", 230, this.data.faceTexDensityMinSqrtDensity, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.ShowAttention("Prefab.FaceTexDensityAvgTooSmall");
		}

		// Token: 0x06001097 RID: 4247 RVA: 0x00007FD1 File Offset: 0x000061D1
		public void CreateFaceTexDensityVrcGUI()
		{
			this.data.faceTexDensityMaxVariance = GUITools.FloatField("【允许最大UV密度方差】:", 180, this.data.faceTexDensityMaxVariance, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.ShowAttention("Prefab.FaceTexDensityVrcTooLarge");
		}

		// Token: 0x06001098 RID: 4248 RVA: 0x00008010 File Offset: 0x00006210
		public void CreateUVRangeGUI()
		{
			this.data.uvRangeMaxUVRange = GUITools.FloatField("【允许最大UV范围】: ", 180, this.data.uvRangeMaxUVRange, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.ShowAttention("Mesh.UVRangeTooLarge");
		}

		// Token: 0x06001099 RID: 4249 RVA: 0x0004C15C File Offset: 0x0004A35C
		private void CreateVertexDensityGUI()
		{
			this.data.vertexDensityMaxDensity = GUITools.FloatField("【允许最大密度】: ", 180, this.data.vertexDensityMaxDensity, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.data.vertexDensityDistance = GUITools.FloatField("【(模拟相机)距离】: ", 180, this.data.vertexDensityDistance, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.data.vertexDensityFov = GUITools.FloatField("【(模拟相机)FOV】: ", 180, this.data.vertexDensityFov, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.ShowAttention("Mesh.VertexDensityTooLarge");
		}

		// Token: 0x0600109A RID: 4250 RVA: 0x0000804F File Offset: 0x0000624F
		private void CreateInvisibleFacesGUI()
		{
			this.ShowAttention("Mesh.HasInvisibleFaces");
		}

		// Token: 0x0600109B RID: 4251 RVA: 0x0004C208 File Offset: 0x0004A408
		private void CreateUVSeamConsistencyGUI()
		{
			this.data.hardedgeUVSeamThreshold = (int)GUITools.FloatField("【阈值(异常像素数)】: ", 180, (float)this.data.hardedgeUVSeamThreshold, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.ShowAttention("Mesh.HardedgeUVSeamConsistency");
		}

		// Token: 0x0600109C RID: 4252 RVA: 0x0004C254 File Offset: 0x0004A454
		private void CreateUVPaddingGUI()
		{
			this.data.uvPaddingThreshold = (int)GUITools.FloatField("【阈值(异常像素数)】: ", 180, (float)this.data.uvPaddingThreshold, Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleInfo));
			this.ShowAttention("Mesh.UVPaddingTooSmall");
		}

		// Token: 0x0600109D RID: 4253 RVA: 0x0004C2A0 File Offset: 0x0004A4A0
		private void ShowAttention(string ruleId)
		{
			RuleInfo ruleInfo;
			this.dicRuleInfo.TryGetValue(ruleId, out ruleInfo);
			bool flag = !string.IsNullOrEmpty(ruleInfo.Description);
			if (flag)
			{
				GUILayout.Label(string.Format("【注意】: {0}", ruleInfo.Description), Singleton<GUIStyleManager>.Instance.GetTStyle(TStyle.RuleAttention), new GUILayoutOption[0]);
			}
		}

		// Token: 0x0600109E RID: 4254 RVA: 0x0000805E File Offset: 0x0000625E
		public override void OnGUI(Rect mainRectangle)
		{
			this.rect = mainRectangle;
			this.GUITitle(false);
			GUITools.DrawSeparator(ScanSettingWindow.I.pageWidth);
		}

		// Token: 0x0600109F RID: 4255 RVA: 0x0004C2FC File Offset: 0x0004A4FC
		protected override void CreateRuleGUI()
		{
			bool flag = true;
			foreach (KeyValuePair<string, RuleConfig> keyValuePair in this.data.dicRuleConfig)
			{
				RuleGUI ruleGUI = null;
				try
				{
					Action openRuleSettingAction = null;
					this.guiActions.TryGetValue(keyValuePair.Key, out openRuleSettingAction);
					ruleGUI = new RuleGUI(openRuleSettingAction)
					{
						ruleKey = keyValuePair.Key,
						fixModule = this.fixModule,
						checkEnabled = keyValuePair.Value.checkEnabled,
						fixEnabled = keyValuePair.Value.fixEnabled,
						hasSrcPath = keyValuePair.Value.hasSrcPath,
						hasSeparateTargetDirSettings = true,
						hasWhiteList = this.data.hasWhiteList,
						isSeparateDirSettingsEnabled = keyValuePair.Value.isSeparateDirSettingsEnabled,
						targetConfig = new List<ScanAssetsConfig>(keyValuePair.Value.targetConfig),
						ignoreConfig = new List<ScanAssetsConfig>(keyValuePair.Value.ignoreConfig)
					};
					ruleGUI.ruleName = this.dicRuleInfo[keyValuePair.Key].ruleName;
					ruleGUI.description = this.dicRuleInfo[keyValuePair.Key].Description;
					ruleGUI.RulePriority = this.dicRuleInfo[keyValuePair.Key].RulePriority;
				}
				catch (Exception ex)
				{
					Debug.LogError(keyValuePair.Key);
					Debug.LogError(ex.Message + "\n" + ex.StackTrace);
					ScanLog.Instance.LogInfo("LoadRuleList", ex.Message + "\n" + ex.StackTrace);
				}
				bool flag2 = flag;
				if (flag2)
				{
					ruleGUI.isShowRuleSetting = true;
					flag = false;
				}
				this.ruleGUIs.Add(ruleGUI);
			}
		}

		// Token: 0x040009D5 RID: 2517
		private Dictionary<string, Action> guiActions = new Dictionary<string, Action>();
	}
}
